<template>
  <div class="all-artist">
    <div
      v-for="item of artists"
      class="each-artist"
      @click="goArtist(item.id)"
      :key="item.id"
    >
      <img v-lazy="item.img1v1Url" />
      <p>{{ item.name }}</p>
    </div>
  </div>
</template>

<script lang="ts">
import { APIType } from "@/api";
import { CommonIdType } from "@/model/id-or-enum.model";
import { Artist } from "@/model/music-info.model";
import { Vue, Component } from "vue-property-decorator";
import Router from "vue-router";
import { Route } from "vue-router";
@Component({})
export default class ArtistSimiComponent extends Vue {
  public artists: Artist[] = [];

  $api: APIType;
  $route: Route;
  $router: Router;

  mounted() {
    this.$api.getSimiArtist(this.$route.params.id).then((result) => {
      this.artists = result;
    });
  }
  goArtist(id: CommonIdType) {
    this.$router.push({ path: `/artist/${id}` }).catch((err) => err);
  }
}
</script>

<style lang="scss" scoped>
.all-artist {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  .each-artist {
    width: 49%;
    > img {
      width: 100%;
    }
    > p {
      text-align: center;
      height: 0.5rem;
      line-height: 0.5rem;
      color: #666;
    }
  }
}
</style>
